<template>
	<view class="partner-list">
		<view class="partner-item" v-for="(item,index) in partnerList" :key="index">
			<view class="parnter-info">
				<image class="partner-avatar" :src="item.headimg" mode="aspectFit"></image>
				<view class="">
					<view class="partner-name">{{item.partner_name}}</view>
					<view class="partner-ctime">加入时间：{{item.create_time}}</view>
				</view>
			</view>
			<view class="partner-share">份额<text class="share-value">{{item.proportion}}</text></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				page_size: 15,
				page_count: 1,
				partnerList: []
			}
		},
		onLoad(e) {
			this.recommend_id = e.id;
			if (uni.getStorageSync('token')) {
				this.getList();
			} else {
				setTimeout(() => {
					this.$refs.login.open('/plugpages/rebate/partner-list');
				});
			}
		},
		methods: {
			getList() {
				this.$api.sendRequest({
					url: '/partner/api/partner/getPartnerlist',
					data: {
						page: this.page,
						page_size: this.page_size
					},
					success: res => {
						let newArr = [];
						newArr = res.data.list;
						newArr.forEach(v => {
							v.create_time = this.$util.timeStampTurnTime(v.create_time).substring(0, 19);
						});
						this.partnerList = this.partnerList.concat(newArr);
						this.page_count = res.data.page_count;
					}
				});
			},
			nextPage() {
				if (this.page < this.page_count) {
					this.page++;
					this.getList();
				}
			}
		},
		onReachBottom() {
			this.nextPage();
		}
	}
</script>

<style lang="scss" scoped>
	@import '../public/css/style.scss';

	.partner-list {
		padding: 0 30rpx;
		background-color: #fff;

		.partner-item {
			padding: 40rpx 0;
			@include flex(space-between, center);
			border-bottom: 1rpx solid #E8E8E8;

			&:last-child {
				border-bottom: none;
			}

			.parnter-info {
				@include flex(flex-start, center);

				.partner-avatar {
					flex-shrink: 0;
					margin-right: 20rpx;
					width: 88rpx;
					height: 88rpx;
					border-radius: 88rpx;
					border: 1rpx solid #E8E8E8;
				}

				.partner-name {
					font-size: 32rpx;
					color: #000000;
					line-height: 45rpx;
				}

				.partner-ctime {
					margin-top: 16rpx;
					font-size: 24rpx;
					color: #909399;
					line-height: 34rpx;
				}
			}

			.partner-share {
				font-size: 28rpx;
				color: #303133;
				line-height: 40rpx;
				.share-value {
					margin-left: 8rpx;
				}
			}
		}
	}
</style>
